<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
   
    
    <title>书籍</title>
    
	
<link href="../css/main.css" rel="stylesheet" type="text/css" media="all">
	<style>
#customers
{	text-align:center;
	font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
	width:95%;
	border-collapse:collapse;
}
#customers td
{	
	font-size:1em;
	border:1px solid #98bf21;
	padding:2px 2px 2px 2px;
}
#customers th 
{   
	font-size:2em;
	padding-top:5px;
	padding-bottom:5px;
	background-color:#A7C942;
	color:#ffffff;
}
#customers tr.alt td 
{
	color:#000000;
	background-color:#EAF2D3;
}
</style>
<script type="text/javascript">
function buybook(id){
 var num=prompt("请输入要购买的数量");
 if(num<0||num!=parseInt(num)){
 alert("商品的数量只能是正整数！");
 
 return;
 }
 
 var b=window.confirm("您确定要购买 "+num+"本书吗？");
 if(b){
 window.location.href="${pageContext.request.contextPath }/servlet/BuyBook?id="+id+"&num="+num;
 }
 
 }
</script>
  </head>
  
  <body >
  
  <%@include file="header.jsp" %>
		
		<!-- 抬头 -->
    <table id="customers">
    <tr >
    	<th>书名</th>
    	<th>图片</th>
    	<th>类型</th>
     	<th>作者</th>
     	<th>出版社</th>
     	<th>简介</th>
      	<th>价格</th>
    	
    </tr>
    <c:forEach var="entry" items="${books }">
     <tr class="alt">
    	<td >${entry.value.bName }<br>
    	<a style="font-size:18px;" href="${pageContext.request.contextPath }/servlet/BuyBookServlet?B_id=${entry.value.bId}" target="_blank">加入购物车</a>
    	<br><a href="javascript:void(0)" onclick="buybook(${entry.value.bId})">购买</a>
    	</td>
    	<td><img  alt="" src="${pageContext.request.contextPath }/img/${entry.value.bSrc }"></td>
    	
     	<td>${entry.value.bClass }</td>
     	<td>${entry.value.bAuthor }</td>
     	<td>${entry.value.bPublish }</td>
     	<td>${entry.value.bBrief }</td>
      	<td>${entry.value.bFixprice }</td>
    	
    </tr>
    
    </c:forEach>
    </table>
  </body>
</html>
